/**
 * @file 场景控制面板的头文件
 *
 * 场景控制面板的类定义
 *
 * @author wq1977@gmail.com
 */


#ifndef __SCENARIOS_CONTROL_PANEL_H__
#define __SCENARIOS_CONTROL_PANEL_H__

#include "wx/filename.h"
#include "OsipProcess.h"
#include "TraceForm.h"
#include "wx/wx.h"

#define DEFAULT_TERM_NUM 10
#ifdef WIN32
#define MAX_TERM_NUM     1000 
#else
#define MAX_TERM_NUM     1000 
#endif

/**
 * @brief 定义场景控制面板
 *
 * 场景控制面板
 * 
 */
class ScenariosControlPanel: public wxPanel
{
public:
    ScenariosControlPanel(wxWindow *parent, wxWindowID id, 
        const wxPoint& pos= wxDefaultPosition, 
        const wxSize& size= wxSize(200,100),
        const long style=wxWANTS_CHARS);///< 构造函数
    ~ScenariosControlPanel();
    int GetSelectScenariosIndex(){ return m_Scenario->GetSelection();};
    void SetSelectScenatio(wxString v){
	for (int i=0;i<(int)m_Scenario->GetCount();i++){
	    wxFileName f1(((wxStringClientData*)m_Scenario->GetClientObject(i))->GetData());
	    wxFileName f2(v);
	    if (f1.GetName() == f2.GetName()){
		m_Scenario->SetValue(m_Scenario->GetString(i));
		m_Scenario->SetSelection(i);
		break;
	    }
	}
    };
    int GetTermNum();
	int GetMinWidth(){return btnReport->GetPosition().x + btnReport->GetSize().x + 20;};
    void SetTermNum(wxString V){m_TermNum->SetValue(V);};
    int GetCallTimes();
    void SetCallTimers(wxString v){m_CallTimes->SetValue(v);};
    int GetCallDuration();
    void SetCallDuration(wxString v){m_CallDuration->SetValue(v);};
    int GetCallHold();
    void SetCallHold(wxString v){m_CallHold->SetValue(v);};
    int GetHeavy();
    void SetHeavy(wxString v){m_CallHeavy->SetValue(v);};
    int GetCaseStyle(){ return m_teststyle->GetSelection();};
    void SetCaseStyle(int v){m_teststyle->SetSelection(v);};
    int GetFinalRuleStyle(){ return m_finalRule->GetSelection();};
    void SetFinalRuleStyle(int v){m_finalRule->SetSelection(v);};
    //bool GetReportOnEnd(){ return m_reportonend->GetValue();};
    bool IsFailOnStop(){ return m_stoponfail->GetValue();};
    void SetFailOnStop(bool v){m_stoponfail->SetValue(v);};
    bool IsSafeStop(){ return m_waitscefinish->GetValue();};
    void SetSafeStop(bool v){m_waitscefinish->SetValue(v);};
    void SetTraceDebug(bool v){m_tracemsg->SetValue(v);};
    void SetTraceSip(bool v){m_tracesip->SetValue(v);};
    void SetTraceError(bool v){m_traceerror->SetValue(v);};
    wxButton *GetStartButton(){return btnStart;};
    bool IsTraceEnable(int Level){
      switch (Level){
      case TL_ERROR:	
	return m_traceerror->GetValue();
      case TL_MESSAGE:
      case TL_MATCH_RULE:
      case TL_WARNING:
	return m_tracemsg->GetValue();
      case TL_SIP_MESSAGE:
      case TL_MESSAGE_RETRANS:
	return m_tracesip->GetValue();
      case -1:
	return true;
      default:
	return false;
      }
    };
    void LockControl(bool unlock=false);
private:
    wxComboBox *m_Scenario;
    wxTextCtrl *m_TermNum;
    wxTextCtrl *m_CallTimes;
    wxTextCtrl *m_CallDuration;
    wxTextCtrl *m_CallHold;
    wxTextCtrl *m_CallHeavy;
    wxButton *btnStart,*btnCfg;
    wxButton *btnStop;
    wxButton *btnReport,*btnStatic;
    wxCheckBox *m_tracemsg;
    wxCheckBox *m_tracesip;
    wxCheckBox *m_traceerror;
    wxCheckBox *m_stoponfail,*m_waitscefinish;
    wxRadioBox *m_teststyle,*m_finalRule;
};

#endif
